import display from '@ohos.display';
import { initInfo } from "./log";
let log = initInfo('getAppWindowSize');


export async function getAppWindowSize(win){
    let width = 1280; // src/main/resources/base/profile/main_pages.json 中的designWidth
    // @ts-ignore
    let prop = await win.getProperties();
    let rect = prop.windowRect;
    let height = rect.height * width / rect.width;
    let lpi = parseFloat((rect.width / width).toFixed(3));
    let dis = await display.getDefaultDisplay();
    let dpi = parseFloat((dis.densityDPI / 160).toFixed(3));
    let res = {
        width: width,
        height: Math.floor(height),
        pageW: rect.width,
        pageH: rect.height,
        dpi: dpi,
        lpi: lpi
    };
//    log('getAppWindowSize res:' + JSON.stringify(res));
    return res;
}